package vns.server;

import javax.jdo.PersistenceManager;

import vns.client.service.ObjectTypeTextService;
import vns.server.domain.ObjectTypeText;
import vns.shared.ObjectTypeTextDTO;

import com.google.appengine.api.datastore.Key;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;

public class ObjectTypeTextServiceImpl extends RemoteServiceServlet 
		implements ObjectTypeTextService{

	@Override
	public ObjectTypeTextDTO Create(ObjectTypeTextDTO opTextDTO) {
		PersistenceManager pm=PMF.get().getPersistenceManager();
		ObjectTypeText action=null;
		try{
			action=new ObjectTypeText(opTextDTO);
			pm.makePersistent(action);
		}finally{
			pm.close();
		}
		return action.toDTO();
	}

	@Override
	public ObjectTypeTextDTO load(Key id) {
		PersistenceManager pm=PMF.get().getPersistenceManager();
		ObjectTypeTextDTO actionDTO=null;
		try{
			ObjectTypeText action = pm.getObjectById(ObjectTypeText.class,id);	
			actionDTO=action.toDTO();
		}finally{
			pm.close();
		}
		return actionDTO;
	}

	@Override
	public ObjectTypeTextDTO Update(ObjectTypeTextDTO opTextDTO) {
		PersistenceManager pm=PMF.get().getPersistenceManager();
		ObjectTypeText action=null;
		try{
			action=pm.getObjectById(ObjectTypeText.class,opTextDTO.getId());
			action.updatefromDTO(opTextDTO);
		}finally{
			pm.close();
		}
		
		return action.toDTO();
	}

	@Override
	public boolean remove(Key id) {
		PersistenceManager pm=PMF.get().getPersistenceManager();
		try{
			ObjectTypeText action= pm.getObjectById(ObjectTypeText.class,id);
			if(action!=null){
				pm.deletePersistent(pm.getObjectById(ObjectTypeText.class,id));
			}
		}finally{
			pm.close();
		}
		return true;
	}

}
